home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / hdf / unix / examples.lha / examples / sds / sdsampl1F.f < prev   
Encoding:
Text File  |  1991-10-08  |  1.6 KB  |  69 lines

  1.       
  2.       program sdsampl1
  3. C
  4. C
  5. C  Program to write out a small SDS, then read it back in and compare
  6. C  the results.
  7. C
  8. C  Input file:  none
  9. C  Output file: test.hdf
  10. C
  11.  
  12.       integer dsgdims, dsgdata, dssdims
  13.       integer rows, cols
  14.       integer isOK
  15.       integer ret, i, j
  16.       integer rank, inRank
  17.       integer shape(2), inShape(2)
  18.       real    pressure(3,4), inPressure(3,4)
  19.       
  20.       isOK = 1
  21.       rows = 3
  22.       cols = 4
  23.       rank = 2
  24.       shape(1) = rows
  25.       shape(2) = cols
  26.       
  27.       do 110 i = 1, rows
  28.         do 100 j = 1, cols
  29.           pressure(i,j) = i+10*j
  30.   100   continue
  31.   110 continue
  32.  
  33. C Write data to file
  34.       ret = dssdims(rank, shape)
  35.       ret = dspdata('test.hdf',2, shape, pressure)
  36.  
  37. C Read data back
  38.       ret = dsgdims('test.hdf',inRank, inShape, 2)
  39.       ret = dsgdata('test.hdf',inRank, inShape, inPressure)
  40.  
  41. C Compare information read in with original information
  42.       print *,  'Output rank is:', rank
  43.       print *,  'Input rank is: ', inRank
  44.       print *,  'Output shape is :', shape(1), shape(2)
  45.       print *,  'Input shape is  :', InShape(1), inShape(2)
  46.  
  47.       do 210 i = 1, rows
  48.         do 200 j = 1, cols
  49.           if (pressure(i,j) .ne. inPressure(i,j)) then
  50.              print *, 'Array position ',i,j,'is different'
  51.          isOK = 0
  52.           endif
  53.   200   continue
  54.   210 continue
  55.  
  56.       do 300 i=1,rows
  57.         print *, 'out:',(pressure(i,j),j=1,cols)
  58.         print *, ' in:',(inPressure(i,j),j=1,cols)
  59.     print *
  60.   300 continue
  61.       
  62.       print *
  63.       if (isOK .eq. 1) then
  64.      print *,"Test of SDS data file read/write successful !"
  65.       endif
  66.       print *
  67.  
  68.       end
  69.